<?php
namespace app\common\model;

use think\Db;
use think\Model;

/**   YSF
 *    评价标签模型
 *    Date: 2018/9/5
 * Class EvaluateLabelModel
 * @package app\common\model
 */
class EvaluateLabelModel extends Model
{
    // 表名
    protected $dbName = 'evaluate_label';

    // 连表列表查询
    public function getJoinAll($where=[], $join, $field='*')
    {
        $result = Db::name($this->dbName)
                ->alias('a')
                ->where($where)
                ->join($join)
                ->field($field)
                ->select();
        return $result;
    }

    // 列表查询
    public function getAll($where=[], $page=1, $pageSize=100, $field='*', $order='')
    {
        $result = Db::name($this->dbName)
                ->where($where)
                ->field($field)
                ->page($page,$pageSize)
                ->order($order)
                ->select();
        return $result;
    }

    // 数量统计
    public function getCount($where)
    {
        $result = Db::name($this->dbName)
            ->where($where)
            ->count();
        return $result;
    }

    // 单条查询
    public function getOne($where=[], $field='*')
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->field($field)
                    ->find();
        return $result;
    }

    // 添加操作
    public function add($data)
    {
        $result = Db::name($this->dbName)
                ->insertGetId($data);
        return $result;
    }

    // 编辑操作
    public function edit($where, $data)
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->update($data);
        return $result;
    }

}